What is the logic of binary search program